<template lang="jade">
div#app
  div.return-bar(@click="back()")
    i.iconfont &#xe668;
    {{item.abstract1.name}}
  div.detail-page

    ul.productlist.detail_top
      li
        div.title
          span.name {{item.abstract1.name}}
          span.fr 起投金额:50万元
        flexbox
          flexbox-item(style="-ms-flex: 1.7;flex: 1.7;-webkit-box-flex: 1.7;")
            span 借款金额
            b {{item.abstract1.account}}元
          flexbox-item
            span 约定收益率
            b.mtxt {{item.abstract1.borrow_apr}}%
          flexbox-item
            span 借款期限
            b {{item.abstract1.borrow_period}}个月
          flexbox-item
            a.p_btn_nob.tcenter {{status}}

        flexbox
          flexbox-item(:span="6")
            剩余可投金额:{{item.abstract1.pick}}元
          flexbox-item
            progress(:percent="item.abstract1.percentage", :show-cancel="false")
          flexbox-item(:span="2")
            span.mtxt {{item.abstract1.percentage}}%



    ul.productdetail
      li
        i.iconfont &#xe6e0;
        span 还款方式
        span.fr {{item.abstract1.borrow_style}}

      li
        i.iconfont &#xe644;
        span 抵押率
        span.fr {{item.abstract1.rate}}%

      li
        i.iconfont &#xe646;
        span 摘标时间
        span.fr {{item.abstract1.deadline}}

      li
        i.iconfont &#xe645;
        span 预期收益
        span.fr {{item.abstract1.profit}}

      li(v-link="{ path: '/invest/group-sub/6?groupId='+groupId }")
        i.iconfont &#xe63c;
        span 房利宝介绍
        span.fr
          i.iconfont.gtxt &#xe600;

    ul.cbox.hl.producthl(style="margin-bottom: 5rem;")
      li
        a(v-link="{ path: '/invest/group-sub/1?groupId='+groupId }")
          i
            img(src="../../assets/images/invest/detail-hl-icon1.png")
          span 借款信息
      li
        a(v-link="{ path: '/invest/group-sub/2?groupId='+groupId }")
          i
            img(src="../../assets/images/invest/detail-hl-icon5.png")
          span 评估报告
      li
        a(v-link="{ path: '/invest/group-sub/3?groupId='+groupId }")
          i
            img(src="../../assets/images/invest/detail-hl-icon3.png")
          span 摘标记录
      li
        a
          i
            img(src="../../assets/images/invest/detail-hl-icon6.png")
          span 我要分享



    section.form
        div.postForm
          input.money(value="500000", v-model="deposit",placeholder="请输入1万的整数倍数，最低50万元",autocomplete="off")
          input(type="hidden",name="borrow_nid",v-model="groupId")
          span.rmb 元
          ul.cbox
            li.balance
              span 可用余额￥
                b {{balance}}
                元
            li.btn
              input.goPay(@click="book()", value="立即投标")
</template>

<style>
@import '~vux/dist/vux.css';
</style>

<script>
import '../../assets/sass/invest/invest.scss'
import {Api_Group_Detail} from '../../config/api'
import DialogPage from '../../components/common/dialog'
import {Progress, Flexbox, FlexboxItem} from 'vux'

export default{

	data () {
		return{
			groupId:'',
			item:[],
      balance:'',
      deposit:'',
	    showDialog: false,
	    deposit:'',
	    total_money:'',
	    typeClass:"noshow",
      status:'',
	    msg:'<div class="dialog"><div class="content"><span class="icon"></span><div class="title">恭喜您摘标成功</div><div class="subtitle"><i class="left"></i>理财金额<i class="right"></i></div><div class="total"> <span>¥</span><b>300</b><span>万元</span></div><div class="despoit">已支付定金10万元</div><div class="info"><div class="item"><b>约定收益率</b><strong>12</strong><span>万元</span></div><div class="item"><b>借款期限</b><strong>1</strong><span>个月</span></div></div><div class="extra"><span><i class="iconfont"></i><em>评估值:600万元</em></span><span><i class="iconfont"></i><em>抵押率:50%</em></span></div></div></div>',
      wx_share:{"title":'', "link":window.location.href, "img":'http://www.uximoney.com/themes/blue/img/logo-temp.png', "desc":''}
		}
	},

	components:{
		DialogPage,
    Progress,
    Flexbox,
    FlexboxItem
	},

	methods:{
		show(){
			this.$children[0].show = true
			//this.dialog.template = "123"
			//this.$children[0].msg = true
			//console.log(this.template)
		},



		hide(){
			this.$children[0].show = false;
		},
		fetch:function(next){

			var that = this;
      this.$store.dispatch('setShowLoading', true);
			this.$http({ url:Api_Group_Detail+'/name_no/'+this.groupId, method:'POST' }).then(function(rs){
				//console.log(rs.data.data);
        this.$store.dispatch('setShowLoading', false);
				that.item = rs.data.data;
				that.total_money = that.item.abstract1.account;
        that.status = rs.data.msg
        that.balance = rs.data.balance;

        document.title = that.item.abstract1.name + " - 有喜财富房利宝"

        //微信分享
       /* this.wx_share.desc = "年化收益高达12%，投资人直接放款给借款人，平台不接触资金!"
        this.wx_share.title = "抵.理财介绍，深圳房产直接抵押到投资人名下"
        this.wx_share.img = that.item.assess.property_guise;
        this.global.wxset(this.wx_share)*/



				next()
			})
		},
		book(){
			var that = this;
			if(that.deposit==""){
				alert("请输入投资金额!");
				return false;
			}else{

				if(isNaN(that.deposit)){
				   alert("你输入的不是数字");
				   return false;
				}

				console.log(that.deposit);

				if( that.deposit < 500000){
				   alert("摘金不小于50万");
				   return false;
				}

				if( that.deposit % 10000!=0){
				   alert("输入的数字要为1万的倍数!");
				   return false;
				}

			}

			//this.$router.go('/group-sub/5?groupId='+this.groupId+'&deposit='+that.deposit);
      this.$router.go('/invest/group-sub/5?groupId='+this.groupId+'&deposit='+that.deposit);
		},

		back(){
			//this.$route.router.go('/')
      this.$route.router.go('/invest/index?productype=group')
		}
	},
	route:{
	    activate ( transition ) {
	    	this.groupId = transition.to.params.groupId
			//this.dialog.template = '<div class="dialog"><div class="content"><span class="icon"></span><div class="title">恭喜您摘标成功</div><div class="subtitle"><i class="left"></i>理财金额<i class="right"></i></div><div class="total"> <span>¥</span><b>300</b><span>万元</span></div><div class="despoit">已支付定金10万元</div><div class="info"><div class="item"><b>约定收益率</b><strong>12</strong><span>万元</span></div><div class="item"><b>借款期限</b><strong>1</strong><span>个月</span></div></div><div class="extra"><span><i class="iconfont"></i><em>评估值:600万元</em></span><span><i class="iconfont"></i><em>抵押率:50%</em></span></div></div></div>'
			this.fetch(function(){
				transition.next();
			});
	    }
	}
}
</script>
